/**
 * 套餐标签工具函数
 * 统一各页面中套餐版本标签的颜色标准
 */

/**
 * 获取套餐标签类型
 * @param packageName 套餐名称
 * @returns CustomTag 组件的 type 属性值
 */
export function getPackageTagType(packageName: string): string {
  const typeMap: Record<string, string> = {
    "标准版": "version-standard",
    "Pro版": "version-pro",
    "Pro Max版": "version-pro-max",
    "专业版 Pro": "version-pro",
    "专业版 Pro Max": "version-pro-max"
  }
  return typeMap[packageName] || "version-standard"
}

/**
 * 获取套餐标签颜色配置
 * 用于直接设置标签的颜色和背景色
 */
export const PACKAGE_TAG_COLORS = {
  "标准版": {
    backgroundColor: "#ffffff",
    borderColor: "#e5e7eb",
    color: "#0a0a0a"
  },
  "Pro版": {
    backgroundColor: "#030212",
    borderColor: "#030212",
    color: "#ffffff"
  },
  "Pro Max版": {
    backgroundColor: "#edeef2",
    borderColor: "#edeef2",
    color: "#030212"
  }
} as const

/**
 * 套餐优先级排序
 * 用于对套餐进行排序显示
 */
export const PACKAGE_PRIORITY = {
  "标准版": 1,
  "Pro版": 2,
  "Pro Max版": 3
} as const

/**
 * 根据优先级对套餐数组进行排序
 * @param packages 套餐名称数组
 * @returns 排序后的套餐数组
 */
export function sortPackagesByPriority(packages: string[]): string[] {
  return packages.sort((a, b) => {
    const priorityA = PACKAGE_PRIORITY[a as keyof typeof PACKAGE_PRIORITY] || 0
    const priorityB = PACKAGE_PRIORITY[b as keyof typeof PACKAGE_PRIORITY] || 0
    return priorityA - priorityB
  })
}
